<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>会员等级</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.all.js"></script>
	</head>

	<body>
		<!--新增弹出框开始-->
		<div class="maskbox">
			<form class="form form-horizontal" id="form-admin-add" method="post">
				<div class="shxx_row clearfix">
					<div class="right">
						<div class="htrig_box">
							<div class="htrig_con">
								<input type="text" name="level_name" id="level_name" class="chax_input chax_input2" placeholder="等级名称" style="width: 250px; margin-top: 20px;">
								<input type="text" name="discount" id="discount" class="chax_input chax_input2" placeholder="等级折扣" style="width: 200px; margin-top: 20px;">%
							</div>
						</div>
					</div>
				</div>
				<div class="add_btnbox">
					<button type="button" class="add_btn_yes" id="tijiao">确定</button>
				</div>
			</form>
		</div>
	</body>

</html>
<script>
	$('#tijiao').click(function() {
		var level_name  = $('#level_name').val;
		var discount = $('#discount').val();
		
		if(level_name.trim() == ""){
			layer.msg('等级名称不能为空');
			return;
		}
		
		if(discount.trim() == ""){
			layer.msg('等级折扣不能为空');
			return;
		}
		
		
		
		$.ajax({
			type: 'post',
			data: {
				level_name: $('#level_name').val(),
				discount: $('#discount').val()
			},
			url: "{:url('accounts/user_level_add')}",
			success: function(data) {
				if(data.code == 200) {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					}, function() {
						window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					});
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}

			},
			error: function(XmlHttpRequest, textStatus, errorThrown) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1000
				});
			}
		});
	});
</script>